/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007-2008 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.basics.manager;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

import com.genia.toolbox.basics.bean.CsvConfiguration;
import com.genia.toolbox.basics.bean.MutableCsvConfiguration;
import com.genia.toolbox.basics.exception.technical.TechnicalException;

/**
 * Manager to handle Csv files.
 */
public interface CsvManager
{

  /**
   * returns the default Cvs configuration.
   * 
   * @return the default Cvs configuration
   */
  public abstract MutableCsvConfiguration defaultCsvConfiguration();



  /**
   * parse a csv File.
   * 
   * @param configuration
   *          the configuration to use for the parsing
   * @param csvFile
   *          the file to parse
   * @return the lines of the cvs file
   * @throws TechnicalException
   *           if an error occured
   */
  public String[][] parseCsv(CsvConfiguration configuration, File csvFile)
      throws TechnicalException;



  /**
   * parse a csv File.
   * 
   * @param csvFile
   *          the file to parse
   * @return the lines of the cvs file
   * @throws TechnicalException
   *           if an error occured
   */
  public String[][] parseCsv(File csvFile)
      throws TechnicalException;



  /**
   * parse a csv File.
   * 
   * @param configuration
   *          the configuration to use for the parsing
   * @param input
   *          the file to parse
   * @return the lines of the cvs file
   * @throws TechnicalException
   *           if an error occured
   */
  public String[][] parseCsv(CsvConfiguration configuration, InputStream input)
      throws TechnicalException;



  /**
   * parse a csv File.
   * 
   * @param input
   *          the file to parse
   * @return the lines of the cvs file
   * @throws TechnicalException
   *           if an error occured
   */
  public String[][] parseCsv(InputStream input)
      throws TechnicalException;



  /**
   * print a csv file.
   * 
   * @param configuration
   *          the configuration to use for writing
   * @param comments
   *          the comments to print or <code>null</code> if no comment must be
   *          print
   * @param data
   *          the datas to print
   * @param output
   *          the output to print to
   * @throws TechnicalException
   *           if an error occured
   */
  public void printCsv(CsvConfiguration configuration, List<String> comments, List<String[]> data, OutputStream output)
      throws TechnicalException;



  /**
   * print a csv file.
   * 
   * @param comments
   *          the comments to print or <code>null</code> if no comment must be
   *          print
   * @param data
   *          the datas to print
   * @param output
   *          the output to print to
   * @throws TechnicalException
   *           if an error occured
   */
  public void printCsv(List<String> comments, List<String[]> data, OutputStream output)
      throws TechnicalException;

}
